 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>

/*字符设备操作函数集，open函数实现*/
static int xxx_open(struct inode *inode, struct file *filp)
{
    return 0;
}
/*字符设备操作函数集，.read函数实现*/
static ssize_t xxx_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
{
    return 0;
}

/*字符设备操作函数集，.read函数实现*/
static ssize_t xxx_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *off)
{
    return 0;
}

/*字符设备操作函数集，.release函数实现*/
static int xxx_release(struct file *file, unsigned int cmd, unsigned long arg)
{
    return 0;
}
/*字符设备操作函数集*/
static struct file_operations xxx_fops = {
	.owner = THIS_MODULE,
	.open = xxx_open,
	.read = xxx_read,
	.write = xxx_write,
	.release = xxx_release,
	.unlocked_ioctl = xxx_ioctl,
};


/* probe 函数 */
static int xxx_probe(struct spi_device *spi)
{
	/* 具体函数内容 */
	return 0;
}

/* remove 函数 */
static int xxx_remove(struct spi_device *spi)
{
	/* 具体函数内容 */
	return 0;
}
/* 传统匹配方式，ID列表 */
static const struct platform_device_id xxx_id[] = {
	{"xxx", 0},
	{}
};

/* 设备树匹配列表 */
static const struct of_device_id xxx_of_match[] = {
	{ .compatible = "xxx" },
	{ /* Sentinel */ }
};

/* 驱动结构体 */
static struct platform_driver xxx_driver = {
	.probe = xxx_probe,
	.remove = xxx_remove,
	.driver = {
		.owner = THIS_MODULE,
		.name = "xxx",
		.of_match_table = xxx_of_match,
	},
	.id_table = xxx_id,
};

/* 驱动入口函数 */
static int __init xxx_init(void)
{
	return platform_driver_register(&xxx_driver);
}

/* 驱动出口函数 */
static void __exit xxx_exit(void)
{
	platform_driver_unregister(&xxx_driver);
}

module_init(xxx_init);
module_exit(xxx_exit);

MODULE_AUTHOR("liping");      		//作者信息
MODULE_DESCRIPTION("Linux kernel driver - xxx driver!");  //模块的描述，可以使用modinfo xxx.ko指令来查看
MODULE_VERSION("0.1");             	//模块版本号
MODULE_LICENSE("GPL"); 				//指定license版本
